<?php /* Smarty version 2.6.18, created on 2016-12-09 13:16:35
         compiled from user/user.pms.tpl.php */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index.header.tpl.php", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index.left.tpl.php", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
  <!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <div class="box box-primary">
            <div class="box-header with-border">
				选择权限模板
                <a href="index.php?a=user.pms&user_id=<?php echo $this->_tpl_vars['user_id']; ?>
" class="btn <?php if ($this->_tpl_vars['group_id'] == '0'): ?>btn-default<?php endif; ?>">用户权限</a>
				<?php $_from = $this->_tpl_vars['group_lists']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
                <a href="index.php?a=user.pms&user_id=<?php echo $this->_tpl_vars['user_id']; ?>
&group_id=<?php echo $this->_tpl_vars['value']['group_id']; ?>
" class="btn  <?php if ($this->_tpl_vars['group_id'] == $this->_tpl_vars['value']['group_id']): ?>btn-default<?php endif; ?>"><?php echo $this->_tpl_vars['value']['group_name']; ?>
组权限</a>
				<?php endforeach; endif; unset($_from); ?>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">
              <div class="table-responsive mailbox-messages">
			  <form name="myform" action="" method="post">
                <div class="content_wrap">
		               <ul id="treeDemo" class="ztree"></ul>
                       <ul id="treeDemos" class="ztree"></ul>
	                   <div style="display:none;">
                            被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
                            <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
                            取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
                            <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
	                    </div>
						<div id="hiddenBox"></div>
                   <div class="box-footer text-center">
				         <button type="submit" onclick="c();" class="btn btn-primary"> 提 交</button>
				   </div>
               </div><!--content_wrap-->
			  </form>
              </div>
              <!-- /.mail-box-messages -->
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /. box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index.footer.tpl.php", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<script type="text/javascript" src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script type="text/javascript" src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
<script type="text/javascript">

		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		<?php $_from = $this->_tpl_vars['pms_lists']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
			{ id:<?php echo $this->_tpl_vars['value']['menu_id']; ?>
, pId:<?php echo $this->_tpl_vars['value']['menu_fid']; ?>
, name:"<?php echo $this->_tpl_vars['value']['menu_name']; ?>
", <?php if ($this->_tpl_vars['value']['is_check'] == '1'): ?>checked:true,<?php endif; ?> open:true},
		<?php endforeach; endif; unset($_from); ?>
		];
		
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();
			code.append("<li>"+str+"</li>");
		}
		
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}

} 			
</script>